package mediator
{
	import components.managers.SystemManager;
	import flash.display.DisplayObject;
	import flash.display.Sprite;
	
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;


	public class MainMediator extends Mediator implements IMediator
	{
		public static const NAME:String="MainMediator";

		public static const SET_MOUSE_ENABLED:String="setMouseEnabled";
		public function MainMediator(viewComponent:Object=null)
		{
			super(NAME, viewComponent);
		}

		/**
		 *添加要监听的消息
		 * @return
		 *
		 */
		override public function listNotificationInterests():Array
		{
			return [SET_MOUSE_ENABLED];
		}

		/**
		 *消息处理
		 * @param note
		 *
		 */
		override public function handleNotification(note:INotification):void
		{
			switch (note.getName())
			{
				case SET_MOUSE_ENABLED:
				{
					var b:Boolean=Boolean(note.getBody());
					SystemManager.rootStage.mouseChildren=b;
					break;
			}
		}
		}

		/**
		 *获取界面
		 * @return
		 *
		 */
		public function get component():Main
		{
			return viewComponent as Main;
		}
		
		public function addChild(skin:DisplayObject):void
		{
			component.addChild(skin);
		}
		
		public function addChildAt(skin:DisplayObject,index:int=0):void
		{
			component.addChildAt(skin,index);
		}
		
		public function removeChild(skin:DisplayObject):void
		{
			if(component.contains(skin))
				component.removeChild(skin);
		}
		public function addViewDisplay(skin:DisplayObject):void
		{
			component.addViewDisplay(skin);
	}
		public function removeViewDisplay(skin:DisplayObject):void
		{
			component.removeViewDisplay(skin);
}
	}
}